home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / Translation.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  10.0 KB  |  305 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Translation.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__TRANSLATION__') = 'UNDEFINED' THEN
  18. __TRANSLATION__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24. ;        include 'ConditionalMacros.a'                                ;
  25.  
  26.     IF &TYPE('__FILES__') = 'UNDEFINED' THEN
  27.     include 'Files.a'
  28.     ENDIF
  29. ;        include 'MixedMode.a'                                        ;
  30. ;        include 'OSUtils.a'                                        ;
  31. ;            include 'Memory.a'                                        ;
  32.  
  33.     IF &TYPE('__COMPONENTS__') = 'UNDEFINED' THEN
  34.     include 'Components.a'
  35.     ENDIF
  36.  
  37.     IF &TYPE('__TRANSLATIONEXTENSIONS__') = 'UNDEFINED' THEN
  38.     include 'TranslationExtensions.a'
  39.     ENDIF
  40. ;        include 'Quickdraw.a'                                        ;
  41. ;            include 'QuickdrawText.a'                                ;
  42.  
  43. domCannot                        EQU        0
  44. domNative                        EQU        1
  45. domTranslateFirst                EQU        2
  46. domWildcard                        EQU        3
  47.  
  48. ; 0L terminated array of OSTypes, or FileTypes
  49. ; Progress dialog resource ID
  50. kTranslationScrapProgressDialogID EQU        -16555
  51.  
  52. ; block of data that describes how to translate
  53. FileTranslationSpec     RECORD    0
  54. componentSignature         ds.l    1
  55. translationSystemInfo     ds.l    1
  56. src                         ds        FileTypeSpec
  57. dst                         ds        FileTypeSpec
  58. sizeof                     EQU    48
  59.                         ENDR
  60.  
  61. ;****************************************************************************************
  62. ;* 
  63. ;*   GetFileTypesThatAppCanNativelyOpen
  64. ;* 
  65. ;*  This routine returns a list of all FileTypes that an application can open by itself
  66. ;* 
  67. ;*  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  68. ;*             appSignature        signature (creator) of application
  69. ;*             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  70. ;* 
  71. ;*  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  72. ;
  73.     IF GENERATING68K THEN
  74.         Macro
  75.         _GetFileTypesThatAppCanNativelyOpen
  76.             moveq    #28,d0
  77.             dc.w     $ABFC
  78.         EndM
  79.     ELSE
  80.         IMPORT    GetFileTypesThatAppCanNativelyOpen
  81.     ENDIF
  82.  
  83. ;****************************************************************************************
  84. ;* 
  85. ;*  ExtendFileTypeList
  86. ;* 
  87. ;*  This routine makes a new list of file types that can be translated into a type in the given list
  88. ;*  Used by StandardFile
  89. ;* 
  90. ;*  Enter:    originalTypeList        pointer to list of file types that can be opened
  91. ;*             numberOriginalTypes        number of file types in orgTypeList
  92. ;*              extendedTypeList        pointer to a buffer to be filled with file types
  93. ;*             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  94. ;* 
  95. ;*  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  96. ;*             numberExtendedTypes        number of file types put in extendedTypeList
  97. ;
  98.     IF GENERATING68K THEN
  99.         Macro
  100.         _ExtendFileTypeList
  101.             moveq    #9,d0
  102.             dc.w     $ABFC
  103.         EndM
  104.     ELSE
  105.         IMPORT    ExtendFileTypeList
  106.     ENDIF
  107.  
  108. ;****************************************************************************************
  109. ;* 
  110. ;* 
  111. ;*  This routine checks if a file can be opened by a particular application.
  112. ;*  If so, it returns if it needs to be translated first, and if so then how.
  113. ;*  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  114. ;*  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  115. ;* 
  116. ;*  Enter:    targetDocument        document to check if it can be opened
  117. ;*             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  118. ;*             appSignature        signature (creator) of application to open doc
  119. ;*             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  120. ;*             onlyNative            whether to consider if document can be translated before opening
  121. ;*             howToOpen            pointer to buffer in which to put how the document can be opened
  122. ;*             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  123. ;* 
  124. ;*  Exit:    howToOpen            whether file needs to be translated to be read
  125. ;*             howToTranslate        if file can be translated, buffer filled in with how to translate
  126. ;*             returns                noErr, noPrefAppErr
  127. ;
  128.     IF GENERATING68K THEN
  129.         Macro
  130.         _CanDocBeOpened
  131.             moveq    #30,d0
  132.             dc.w     $ABFC
  133.         EndM
  134.     ELSE
  135.         IMPORT    CanDocBeOpened
  136.     ENDIF
  137.  
  138. ;****************************************************************************************
  139. ;* 
  140. ;*  GetFileTranslationPaths
  141. ;* 
  142. ;*  This routine returns a list of all ways a translation can occure to or from a FileType.
  143. ;*  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  144. ;* 
  145. ;*  Enter:    srcDoc            source file or NULL for all matches
  146. ;*             dstDoc            destination FileType or NULL for all matches
  147. ;*             maxResultCount
  148. ;*             resultBuffer
  149. ;*  Exit:    number of paths
  150. ;
  151.     IF GENERATING68K THEN
  152.         Macro
  153.         _GetFileTranslationPaths
  154.             moveq    #56,d0
  155.             dc.w     $ABFC
  156.         EndM
  157.     ELSE
  158.         IMPORT    GetFileTranslationPaths
  159.     ENDIF
  160.  
  161. ;****************************************************************************************
  162. ;* 
  163. ;*  GetPathFromTranslationDialog
  164. ;* 
  165. ;*  This routine, with a given document, application, and a passed typelist will display the
  166. ;*  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  167. ;*  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  168. ;*  The routine returns the translation path information.
  169. ;* 
  170. ;*  Enter:    theDocument            FSSpec to document to open
  171. ;*             theApplication        FSSpec to application to open document
  172. ;*             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  173. ;*                                 you would like the documented translated to.  Order most perferred
  174. ;*                                 to least.
  175. ;* 
  176. ;*  Exit:    howToOpen            Translation method needed to open document
  177. ;*             howToTranslate        Translation specification
  178. ;*             returns                Any errors that might occur.
  179. ;
  180.     IF GENERATING68K THEN
  181.         Macro
  182.         _GetPathFromTranslationDialog
  183.             moveq    #55,d0
  184.             dc.w     $ABFC
  185.         EndM
  186.     ELSE
  187.         IMPORT    GetPathFromTranslationDialog
  188.     ENDIF
  189.  
  190. ;****************************************************************************************
  191. ;* 
  192. ;*   TranslateFile
  193. ;* 
  194. ;*  This routine reads a file of one format and writes it to another file in another format. 
  195. ;*  The information on how to translated is generated by the routine CanDocBeOpened.
  196. ;*  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  197. ;*  The destination file must not exist.  It is created by this routine.  
  198. ;* 
  199. ;*  Enter:    sourceDocument            input file to translate
  200. ;*             destinationDocument        output file of translation
  201. ;*             howToTranslate            pointer to info on how to translate
  202. ;*  Exit:    returns                    noErr, badTranslationSpecErr 
  203. ;
  204.     IF GENERATING68K THEN
  205.         Macro
  206.         _TranslateFile
  207.             moveq    #12,d0
  208.             dc.w     $ABFC
  209.         EndM
  210.     ELSE
  211.         IMPORT    TranslateFile
  212.     ENDIF
  213.  
  214. ;****************************************************************************************
  215. ;* 
  216. ;*   GetDocumentKindString
  217. ;* 
  218. ;*  This routine returns the string the Finder should show for the "kind" of a document
  219. ;*  in the GetInfo window and in the kind column of a list view.  
  220. ;* 
  221. ;*  Enter:    docVRefNum        The volume containing the document
  222. ;*             docType            The catInfo.fdType of the document
  223. ;*             docCreator        The catInfo.fdCreator of the document
  224. ;*             kindString        pointer to where to return the string
  225. ;* 
  226. ;*  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  227. ;*             returns            noErr, or afpItemNoFound if kind could not be determined
  228. ;
  229.     IF GENERATING68K THEN
  230.         Macro
  231.         _GetDocumentKindString
  232.             moveq    #22,d0
  233.             dc.w     $ABFC
  234.         EndM
  235.     ELSE
  236.         IMPORT    GetDocumentKindString
  237.     ENDIF
  238.  
  239. ;****************************************************************************************
  240. ;* 
  241. ;*  GetTranslationExtensionName
  242. ;* 
  243. ;*  This routine returns the translation system name from a specified TranslationSpec
  244. ;* 
  245. ;*  Enter:    translationMethod    The translation path to get the translation name from
  246. ;* 
  247. ;*  Exit:    extensionName        The name of the translation system
  248. ;*             returns                Any errors that might occur
  249. ;
  250.     IF GENERATING68K THEN
  251.         Macro
  252.         _GetTranslationExtensionName
  253.             moveq    #54,d0
  254.             dc.w     $ABFC
  255.         EndM
  256.     ELSE
  257.         IMPORT    GetTranslationExtensionName
  258.     ENDIF
  259.  
  260. ;****************************************************************************************
  261. ;* 
  262. ;*  GetScrapDataProcPtr
  263. ;* 
  264. ;*  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  265. ;*  get the data to be translated.  The first call TranslateScrap will make to this is to
  266. ;*  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  267. ;*  with a list all the formats that you have available to be translated, and the length of each.
  268. ;*  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  269. ;*  the formats that 'fmts' list said was available.
  270. ;* 
  271. ;*  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  272. ;*             dataH                    Handle in which to put the requested data
  273. ;*             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  274. ;*             
  275. ;*  Exit:    dataH                    Handle is resized and filled with data in requested format
  276. ;
  277. ;****************************************************************************************
  278. ;* 
  279. ;*  TranslateScrap
  280. ;* 
  281. ;*  This routine resizes the destination handle and fills it with data of the requested format.
  282. ;*  The data is generated by translated one or more source formats of data supplied by
  283. ;*  the procedure srcDataGetter.  
  284. ;*  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  285. ;*  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  286. ;* 
  287. ;*  Enter:    sourceDataGetter            Pointer to routine that can get src data
  288. ;*             sourceDataGetterRefCon        Extra parameter for dataGetter
  289. ;*             destinationFormat            Format of data desired
  290. ;*             destinationData                Handle in which to store translated data
  291. ;*             
  292. ;*  Exit:    dstData                        Handle is resized and filled with data in requested format
  293. ;
  294.     IF GENERATING68K THEN
  295.         Macro
  296.         _TranslateScrap
  297.             moveq    #14,d0
  298.             dc.w     $ABFC
  299.         EndM
  300.     ELSE
  301.         IMPORT    TranslateScrap
  302.     ENDIF
  303.  
  304.     ENDIF ; __TRANSLATION__
  305.